package tela.eventociar;

import ferramentas.Query;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ValidarEventoCiar extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        response.setContentType("text/html");
        response.setHeader("Cache-control", "no-cache, no-store");
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Expires", "-1");
        try {
            String cpf = request.getParameter("cpf");
            if (cpf != null) {
                Query q = new Query();
                boolean isCadastrado = q.isUsuarioCadastradoEventoCiar2013(cpf);

                if (isCadastrado) {
                    out.print("false");
                } else {
                    out.print("true");
                }
            }
        } catch (SQLException ex) {
            out.print("true");
        } finally {
            out.close();
        }
    }
}
